package main

import (
	"fmt"
	"regexp"
	"strings"
)

func main() {
	paramMap := map[string]interface{}{
		"regionId":    11,
		"elasticIpId": 21,
	}

	url := "/regions/${regionId}/elasticIps/${elasticIpId}"
	r, _ := regexp.Compile("{[a-zA-Z0-9-_]+}")
	matches := r.FindAllString(url, -1)
	for _, match := range matches {
		fmt.Println(match)
		field := strings.TrimLeft(match, "{")
		field = strings.TrimRight(field, "}")
		value, ok := paramMap[field]
		if !ok {
			continue
		}

		valueStr := fmt.Sprintf("%v", value)
		url = strings.Replace(url, match, valueStr, -1)
	}
	fmt.Println(url)

}
